<!DOCTYPE html>
<html class="no-js" ng-app="test"><!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <title></title>
    <meta content="width=device-width" name="viewport">

    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
    <link href="/dist/release/ui-grid.css" rel="stylesheet">

    <!-- <script src="//code.jquery.com/jquery-2.1.3.min.js"></script> -->
    <script src="/lib/test/angular/1.2.26/angular.js"></script>
    <script src="/dist/release/ui-grid.js"></script>

    <style>
        body {
            padding: 60px;
            min-height: 600px;
        }
        .grid {
            width: 500px;
            height: 400px;
        }
        .placeholder {
            height: 50%;
            width: 50%;
            border: 3px solid black;
            background: #ccc;
        }
    </style>
</head>
<body ng-controller="Main">
<!-- <h1>Test</h1> -->

<!-- <div class="row main"> -->
<h2>Grid</h2>
<button type="button" ng-click="toggleFiltering()">Toggle Filtering</button>
<br>
<br>
<div ui-grid="gridOptions" class="grid" ui-grid-selection></div>

<br>
<br>

<script>
  var app = angular.module('test', ['ui.grid', 'ui.grid.selection']);
  app.controller('Main', function($scope, $http, $timeout,uiGridConstants) {
    $scope.gridOptions = {
      enableFiltering: true,
      onRegisterApi : function(api){
        $scope.gridApi = api;
      },
      // columnDefs: [{}]
    };
    $scope.gridOptions.columnDefs = [ { field: 'id'}, { field: 'name'}, { field: 'age'} ];

    $timeout(getData, 3000);

    // $timeout(getColumns, 2000);

    $scope.toggleFiltering = function(){
      $scope.gridOptions.enableFiltering = !$scope.gridOptions.enableFiltering;
      $scope.gridApi.core.notifyDataChange( uiGridConstants.dataChange.ALL );
    };

    function getData(){
      $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
      .success(function(data) {
        $scope.gridOptions.data = data;
      });
    }

    function getColumns() {
      $scope.gridOptions.enableFiltering = false;
    }
  });
</script>
</body>
</html>
